﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Analysis.Business;

namespace Analysis
{
    public partial class frmProgress : XtraForm
    {
        dbMikro DbMikro;
        public frmProgress()
        {
            InitializeComponent();
            DbMikro = new dbMikro();
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (true) //(new Licensing().CheckEvaluate())
            {
                prgBar.Visible = true;
                Application.DoEvents();
                DbMikro.FiyatFarkiHesapla(dateEdit1.DateTime);
                gridControl1.DataSource = DbMikro.KesilecekFiyatFarklari();
                gridView1.BestFitColumns();
                gridView1.Columns["id"].Visible = false;

                for (int i = 0; i < gridView1.Columns.Count; i++)
                {
                    if (gridView1.Columns[i].ColumnType == typeof(double))
                    {
                        gridView1.Columns[i].DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                        gridView1.Columns[i].DisplayFormat.FormatString = "c2";
                    }
                }
                prgBar.Visible = false;
            }
            else
            {
                MessageBox.Show("Kullanım Süreniz Dolmuştur!\r\nLütfen tr.freelancer@gmail.com adresinden tam sürümünü edinmek için iletişime geçiniz.\r\n");
            }

        }

        private void frmProgress_Load(object sender, EventArgs e)
        {
            dateEdit1.DateTime = DbMikro.SenkronOku();
        }

        private void detayToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (gridView1.FocusedRowHandle > -1)
            {
                int id = Convert.ToInt32(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["id"]));
                frmFaturaDetay detay = new frmFaturaDetay();
                detay.CharID = id;
                detay.ShowDialog(this);
            }
        }
    }
}
